const express = require('express')
const bodyParser = require('body-parser')
const cowsay = require('cowsay')
const path = require('path')
const router = require('./router')

const port = 5000
const app = express()

app.use('/public/', express.static(path.join(__dirname, './public/')))
app.use(
  '/node_modules/',
  express.static(path.join(__dirname, './node_modules/'))
)
app.engine('html', require('express-art-template'))
app.set('views', path.join(__dirname, './views/')) //默认./views 目录

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.use(router)

app.listen(port, () => {
  console.log(
    cowsay.think({
      e: 'Oo',
      text: `Server start at http://localhost:${port}...
Welcome to blog!
I'm Cow `,
      T: 'U',
    })
  )
})
